package com.hb.trade.server.center.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.core.pojo.center.sys.dto.MenuResourceDTO;
import com.hb.core.pojo.center.sys.mapper.MenuResourceMapper;
import com.hb.core.pojo.center.sys.entity.MenuResource;
import com.hb.trade.server.center.sys.service.MenuResourceService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 目录资源信息表 服务实现类
 * </p>
 *
 * @author zjk
 * @since 2021-05-21
 */
@Service
public class MenuResourceServiceImpl extends ServiceImpl<MenuResourceMapper, MenuResource> implements MenuResourceService {

    @Override
    public List<MenuResourceDTO> listAllMenus(MenuResourceDTO menuResource) {
        if (menuResource == null) {
            menuResource = new MenuResourceDTO();
        }
        return baseMapper.listAllMenus(menuResource);
    }

    @Override
    public List<MenuResourceDTO> listTreesWithAuth(Long userId, Integer roleSign) {
        return baseMapper.listTreesWithAuth(userId, roleSign);
    }

    /**
     * 获取指定菜单下的按钮权限
     *
     * @param parentMenuId 为空时获取所有功能按钮权限
     * @return
     */
    @Override
    public List<String> listBtnPermissions(Long parentMenuId) {
        return baseMapper.listBtnPermissions(parentMenuId);
    }

    /**
     * 查询指定角色ID的权限
     *
     * @param roleId
     * @return
     */
    @Override
    public List<MenuResourceDTO> listMenusByRoleId(Long roleId) {
        return baseMapper.listMenusByRoleId(roleId);
    }
}
